
# =====================================
# solve error：UnicodeEncodeError: 'gbk' codec can't encode character '\xXX' in position XX
# =====================================
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer,encoding='gb18030') #改变标准输出的默认编码


from urllib import request

url = 'http://httpbin.org/ip'

# use proxy
handler = request.ProxyHandler({'http':'58.253.153.178:9999'})
# 没几个好用的IP
# set opener
opener = request.build_opener(handler)
# use opener to send request
resp = opener.open(url)

print(resp.read().decode())